Notes & Mini-Essays

> Writing / Notes & Mini-Essays / First Git Steps

First Git Steps

06-04-2025

Tags: Practical Tip, Computer Science, Cheatsheet, Tech and Internet environment


Introduction

What is git?

I admit I had made this note for a public of mostly computer scientists so I found it fair to add this little introduction for people who reasonably have never heard of this, on here (here being neocities). Note that this whole... note, is uncomplete, aimed to people used to working with the terminal (habit which is surprisingly easy to get into I swear) and ultimately just boils down to a quick cheatsheet to start using it on your own.

So what is git? Imagine this scenario: you are working on some kind of project which involves the development (for example) of some kind of software. You are working on it on your computer; while all your coworkers are working on it on theirs. You add something, your coworker removes something, another one adds another feature, while someone else is fixing a bug. How do you all coordinate the lines of code you are working on, in a simple and reliable way? Git is the answer to this. It is a neat little piece of software which coordinates versions; therefore, it fixes the "doc_final.docx" "doc_FINAL_FINAL.docx" "doc_ULTIMATE.docx" problem as well.

The funny thing is that it was developed by Linus Torvalds, the same guy who created the kernel (core part) of what is now known as the Linux Operating System; and it was a quick side project because he needed a solution to that very same synchronization problem. So he made that; and over the course of time, it came to be used by the overwhelming majority of people working on any kind of software on a team, and then some.

Resources

Here is the official Git book, a comprehensive guide. I don't cover in here the download process; in Linux you should be installing it through a package management tool, while on windows you can get the exe from the official git website, here.
Here
is a beautiful Git cheatsheet made by TendTo.

Setup

Configuration

The first thing you should do after installing git is to insert your name and email address in the git configuration. This is important because these will be your signatures every time you make a commit.

You can do the former by using the command git config --global user.name "John Smith", and the latter by doing git config --global user.email johnsmith@example.com.

You should also configurate what your default text editor is: on Linux you need only write the name of the command, as such: git config --global core.editor vim, while Windows needs the full path: git config --global core.editor "C:\Users\USER\AppData\Local\Programs\Microsoft VS Code\bin\code". You can find more information about configuration by entering git help config.

The manual is your best friend. Please consult it. git -h will give you a list of possible commands. You can use git [COMMAND] -h to show descriptions of each of those commands, and git help [COMMAND] to open extensive help about it. There is also a neat little package you can install called tldr, which contains lots and lots of, well, tldr snippets, as a sort of "faq" for many, many other packages out there, including git.

Terminal tab completion, too, is your best friend. Circle most used commands by the up and down arrows; auto-complete commands (such as file names) by typing the first letters, and then pressing tab.

It is generally regarded as good and sensible practice to change the name of your initial branch. The historical name has been master, but it has since been steadily renamed to main. You can do so through the command git config --global init.defaultBranch main.

You can see the full config up to now with the command git config --list. You can add the flag --show-origin to see where the source of each config is. You can also see a single config value with the command git config, such as git config core.editor.

First commands and first project

Source
The first steps to git should be to get your hands on a repository: you can do this either by creating one or by cloning one.

Here's how to create one. First, you should navigate (with your terminal) to a folder which will be the workspace of your project. Good practice would be to organize it inside another folder which holds your other projects, or related projects/resources, but that's your choice. If you are on Linux you can navigate there through the command cd.

This reminds me, I should create a little Linux terminal guide. Although, many people have done this already, quite better than I could right now, so I suggest following theirs for the time being.

Hidden Folders; note: every folder which starts with a dot is "hidden": to make it show on the terminal with the ls command, use the flag -a

Then you can create files either with your GUI of choice or by commands such as touch NAMEFILE.c (that's a c file), touch README.md (that's the README, which will be useful later), and touch LICENSE.

Then run the command git add *.c , git add README.md, git add LICENSE. If you'd like, at any of these steps try running git status to see what the output is. Finally, run git commit -m 'YOUR COMMIT MESSAGE'.

Commit Messages; See here to get an idea of what a good commit message looks like. Starting to commit well early is a good habit. It will not only make others aware that you know what you are doing, but it will be extremely helpful either to yourself or others, when going back at the code. If you write coincise commit messages from the get go, you won't have to wonder what the hell this or that update was about in a few months.

Cloning a repository

You can clone a repository with the command git clone URL. This works with github URLs. Try to clone one of your public github repository, if you have one!

!Git vs GitHub!: Git and Github are two different and separate things. Think Git as a software which can help you coordinate between versions of a software, and GitHub as a web server/platform where software can be stored, hosted, and shared in. GitHub relies on Git for version control.

Optional step: if you don't have one yet, then go create one, by signing up on github.com if you haven't. Github is a good place to share your code, to get feedback on it, and to gradually build a code portfolio. Github is arguably the most used, but know, though, that there are more places like github which allow you to host or self-host your code in a more personal and private way; for example, Gitea or others. At the time of writing, I'm not versed enough in their use to say more about them, though.

Optional step: Here is how to set up GitHub Authentication with SSH (Secure Shell Protocol); with it, you will be able to work on your private repository from your terminal, as the protocol authenticates you with your GitHub account.


Related:

The Seven Golden Rules of a git commit

website inspiration from: Reti Medievali, 2000 UpLast Update: 3/01/2026